Skip to content

fix(engine): Prefer js_error! over JsError::from_opaque#5116

Merged
jedel1043 merged 1 commit intoboa-dev:mainfrom
p0lyw0lf:js_error-instead-of-from_opaque
Mar 28, 2026
Merged

fix(engine): Prefer js_error! over JsError::from_opaque#5116
jedel1043 merged 1 commit intoboa-dev:mainfrom
p0lyw0lf:js_error-instead-of-from_opaque

Conversation

@p0lyw0lf
Copy link
Copy Markdown
Contributor

In a few places, native code was throwing
JsError::from_opaque(js_string!("some literal")). This is allowed, but it is not exactly standard: most users will expect thrown values to be of type Error.

So, where possible, let's convert code using that to instead use the provided js_error! macro, which does generate proper Error objects.

This doesn't touch AbortError, because (1) that's a larger code change, and (2) it might actually be relied on as a sentinel value.

@p0lyw0lf p0lyw0lf requested a review from a team as a code owner March 17, 2026 02:28
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 17, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Mar 17, 2026
@github-actions github-actions Bot added the C-Builtins PRs and Issues related to builtins/intrinsics label Mar 17, 2026
@github-actions
Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,073 50,073 0
Ignored 2,072 2,072 0
Failed 818 818 0
Panics 0 0 0
Conformance 94.54% 94.54% 0.00%

Tested main commit: 197b736bb87523a14b41834c078adbec3059d237
Tested PR commit: e5bd33f426546531ea323801867d5a6d2bb77963
Compare commits: 197b736...e5bd33f

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.72%. Comparing base (6ddc2b4) to head (494a286).
⚠️ Report is 921 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/module/loader/mod.rs 42.85% 4 Missing ⚠️
core/engine/src/interop/into_js_function_impls.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5116       +/-   ##
===========================================
+ Coverage   47.24%   59.72%   +12.48%     
===========================================
  Files         476      589      +113     
  Lines       46892    63471    +16579     
===========================================
+ Hits        22154    37909    +15755     
- Misses      24738    25562      +824     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of nits

Comment on lines +62 to +88
@@ -85,7 +85,7 @@ macro_rules! impl_into_js_function {
match s.try_borrow_mut() {
Ok(mut r) => r( $($id,)* rest.into() ).try_into_js_result(ctx),
Err(_) => {
Err(JsError::from_opaque(js_string!("recursive calls to this function not supported").into()))
Err($crate::js_error!(ReferenceError: "recursive calls to this function not supported"))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also be plain Errors, right?

@jedel1043 jedel1043 removed the C-Builtins PRs and Issues related to builtins/intrinsics label Mar 20, 2026
In a few places, native code was throwing
`JsError::from_opaque(js_string!("some literal"))`. This is allowed, but
it is not exactly standard: most users will expect thrown values to be
of type `Error`.

So, where possible, let's convert code using that to instead use the
provided `js_error!` macro, which does generate proper `Error` objects.

This doesn't touch `AbortError`, because (1) that's a larger code
change, and (2) it might actually be relied on as a sentinel value.
@p0lyw0lf p0lyw0lf force-pushed the js_error-instead-of-from_opaque branch from e5bd33f to 494a286 Compare March 27, 2026 23:38
@p0lyw0lf
Copy link
Copy Markdown
Contributor Author

Hi, sorry for the delay on this! I've addressed the nit & rebased past the merge conflict.

@p0lyw0lf p0lyw0lf requested a review from jedel1043 March 27, 2026 23:38
@jedel1043 jedel1043 added the A-Technical Debt Changes related to technical debt label Mar 27, 2026
@github-actions
Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,732 50,732 0
Ignored 1,426 1,426 0
Failed 805 805 0
Panics 0 0 0
Conformance 95.79% 95.79% 0.00%

Tested main commit: b6e0fb4d8c142db7dc8f3be03a12109f3f4af298
Tested PR commit: 494a2869516ada762160665a0350926e4c633f6a
Compare commits: b6e0fb4...494a286

Copy link
Copy Markdown
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thank you!

@jedel1043 jedel1043 added this pull request to the merge queue Mar 27, 2026
Merged via the queue into boa-dev:main with commit f075094 Mar 28, 2026
22 checks passed
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Mar 28, 2026
@p0lyw0lf p0lyw0lf deleted the js_error-instead-of-from_opaque branch April 17, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Technical Debt Changes related to technical debt

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants